package com.gitee.zeric.codec.generaters;

import com.alibaba.fastjson.JSONObject;

import java.util.Random;

/**
 * @author zj
 * @date 2021/12/17
 */
public class SpecialSymbolGenerater extends AbstractCodeGerator {

    private final static String[] SIGN = {"!", "@", "#", "^",  "(", ")", "_", "[", "]", ";", ",", "."};
    private static final Random random = new Random();

    @Override
    public String generate(String ruleCode,JSONObject jsonObject)  {
        RuleParam param = trans(RuleParam.class, jsonObject);
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < param.getSize(); i++) {
            code.append(SIGN[random.nextInt(SIGN.length)]);
        }
        return code.toString();
    }

    @Override
    protected String[] fields() {
        return new String[]{"size"};
    }
}
